package com.qfedu.openplateform.manager.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.openplateform.manager.dao.ApiMappingMapper;
import com.qfedu.openplateform.manager.entity.ApiMapping;
import com.qfedu.openplateform.manager.service.ApiMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ApiMappingServiceImpl implements ApiMappingService {

    @Autowired
    private ApiMappingMapper apiMappingMapper;

    //查询路由列表
    @Override
    public PageInfo<ApiMapping> getApiMappingList(ApiMapping apiMapping, Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        return new PageInfo<>(apiMappingMapper.getApiMappingList(apiMapping));
    }

    //添加路由
    @Override
    public void addApiMapping(ApiMapping apiMapping) {
       apiMappingMapper.addApiMapping(apiMapping);
    }

    //删除路由
    @Override
    public void deleteApiMapping(int[] ids) {
        for (int id : ids) {
            apiMappingMapper.deleteApiMapping(id);
        }

    }

    //更新路由
    @Override
    public void updateApiMapping(ApiMapping apiMapping) {
        apiMappingMapper.updateApiMapping(apiMapping);
    }
}
